package com.zlkj.pro.modular.business.controller;

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.zlkj.pro.modular.business.model.dto.CustomerDTO;
import com.zlkj.pro.modular.business.model.vo.CustomerVO;
import com.zlkj.pro.modular.business.service.TCustomerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import static com.zlkj.pro.core.consts.ProjectConstants.SERVICE_API_PREFIX;

/**
 * @author liyang
 * @date 2024/4/6
 * @time 14:34
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@ApiResource(name = "客户信息", path = SERVICE_API_PREFIX + "/customer/info")
public class TCustomerController {

    private final TCustomerService customerService;

    @GetResource(name = "分页查询", path = "/findPage")
    public ResponseData findPage(CustomerDTO dto) {
        PageResult<CustomerVO> restData = customerService.findPage(dto);
        return new SuccessResponseData(restData);
    }

    @PostResource(name = "编辑", path = "/edit")
    public ResponseData edit(@RequestBody CustomerDTO dto) {
        boolean restData = customerService.edit(dto);
        return new SuccessResponseData(restData);
    }

    @PostResource(name = "添加", path = "/add")
    public ResponseData add(@RequestBody CustomerDTO dto) {
        //LoginUser user = LoginContext.me().getLoginUser();
        boolean restData = customerService.add(dto);
        return new SuccessResponseData(restData);
    }

}
